#include <string.h>
#include <stdio.h>
#include "test.h"
#include "../buffer.h"
int main(int argc, char **argv)
{
  int len;
  fprintf(stderr, "TEST: " __FILE__ " start\n");
  jsbuf_t *buf = js_buf_new();
  TEST(0, js_buf_size(buf));
  js_buf_write(buf, "hello", strlen("hello"));
  TEST(5, js_buf_size(buf));

  TEST_STRING("hello", js_buf_tochar(buf, &len));
  js_buf_putc(buf, 'h');
  TEST(6, js_buf_size(buf));

  TEST_STRING("helloh", js_buf_tochar(buf, &len));
  js_buf_clear(buf);
  TEST(0, js_buf_size(buf));
  int i;
  for (i = 0; i < 100; i++) {
      js_buf_write(buf, "hello", strlen("hello"));
  }
  TEST(500, js_buf_size(buf));
  js_buf_delete(buf);
  fprintf(stderr, "TEST: " __FILE__ " end\n");
  return 0;
}
